.\"  Copyright (c) 1997, Sun Microsystems, Inc.  All Rights Reserved
.\"  Copyright (c) 2017, Joyent, Inc.
.\" The contents of this file are subject to the terms of the
.\" Common Development and Distribution License (the "License").
.\" You may not use this file except in compliance with the License.
.\"
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
.\" or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions
.\" and limitations under the License.
.\"
.\" When distributing Covered Code, include this CDDL HEADER in each
.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
.\" If applicable, add the following below this CDDL HEADER, with the
.\" fields enclosed by brackets "[]" replaced with your own identifying
.\" information: Portions Copyright [yyyy] [name of copyright owner]
.Dd March 13, 2022
.Dt SESIO 4I
.Os
.Sh NAME
.Nm sesio
.Nd enclosure services device driver interface
.Sh SYNOPSIS
.In sys/scsi/targets/sesio.h
.Sh DESCRIPTION
The
.Nm ses
device driver provides the following ioctls as a means to access
SCSI enclosure services devices.
.Sh IOCTLS
The
.Nm ses
driver supports the following ioctls:
.Bl -tag -width SES_IOCTL_GETSTATE
.It Dv SES_IOCTL_GETSTATE
This ioctl obtains enclosure state in the
.Vt ses_ioctl
structure.
.It Dv SES_IOCTL_SETSTATE
This ioctl is used to set parameters on the enclosure services device.
The
.Vt ses_ioctl
structure is used to pass information into the driver.
.El
.Sh EXAMPLES
.Bl -tag -width "Example 1"
.It Sy "Example 1"
Using the
.Dv SES_IOCTL_GETSTATE
ioctl
.El
.Pp
The following example uses the
.Dv SES_IOCTL_GETSTATE
ioctl to recover 20 bytes of page 4 from a previously opened device.
.Bd -literal -offset 2n
char   abuf[30];
struct ses_ioctl *sesp;
int    status;

sesp = (ses_ioctl *)abuf;
sesp->size = 20;
sesp->page_code = 4;
status = ioctl(fd, SES_IOCTL_GETSTATE, abuf);
.Ed
.Sh ERRORS
.Bl -tag -width ENOTTY
.It Er EIO
The
.Nm ses
driver was unable to obtain data from the enclosure services
device or the  data transfer could not be completed.
.It Er ENOTTY
The
.Nm ses
driver does not support the requested ioctl function.
.It Er ENXIO
The enclosure services device does not exist.
.It Er EFAULT
The user specified a bad data length.
.El
.Sh STRUCTURES
The
.Vt ses_ioctl
structure has the following fields:
.Bd -literal -offset 2n
uint32_t page_size;      /* Size of buffer that follows */
uint8_t  page_code:      /* Page to be read/written */
uint8_t  reserved[3];    /* Reserved; Set to 0 */
.Ed
.Sh ARCHITECTURE
SPARC
X86
.Sh SEE ALSO
.Xr ioctl 2 ,
.Xr ses 4D
